package com.kmxd.ams.core.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import java.util.Objects;

/**
 * 利用类型
 *
 * @author nickbi
 */
public enum UseTypeEnum {

  /** 浏览 */
  ONLINE_BROWSER(1, "浏览"),
  /** 摘录 */
  ONLINE_PRINT(2, "打印"),
  DOWNLOAD(3, "下载水印版本"),
  DOWNLOAD_SOURCE(4, "下载原版"),
  LIVE_READ(5, "现场借阅"),
  LEND_OUT(6, "实物外借"),
  COPY_SEND(7, "复制外借"),
  EXTRACT(8, "摘录"),
  BROWSER_FILE(9, "原文浏览"),
  ;

  @EnumValue private final Integer type;
  private final String desc;

  @JsonValue
  public Integer getType() {
    return type;
  }

  public String getDesc() {
    return desc;
  }

  UseTypeEnum(Integer type, String desc) {
    this.type = type;
    this.desc = desc;
  }

  @JsonCreator
  public static UseTypeEnum getValue(Integer type) {
    return Arrays.stream(values()).filter(x -> Objects.equals(x.type, type)).findAny().orElse(null);
  }
}
